/*
 * @Author: your name
 * @Date: 2021-08-27 11:47:44
 * @LastEditTime: 2021-08-27 14:04:12
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day05\4-数组的定义.js
 */

//1.字面量
var logo = ['ysld.png', 'lankou.png', 'skII.png'];
var arr1 = [100, true, 200.2, 'lankou', { name: 'zs' }];
console.log(logo, arr1);
console.log(typeof logo, typeof arr1); //object object

//2.构造函数 Arry
var strs = new Array(); //等价于var strs=[];
console.log(typeof strs, strs); //object 空数组[]

//数组的使用：索引下标的使用
console.log(logo[0], logo[1], logo[2]);
console.log(logo[-12], logo[5]); //undefined undefined
console.log(logo[200.2], logo[false], logo['abc']) //undefined undefined undefined

//重新赋值

logo[0] = '雅诗兰黛';
logo[3] = '百草';
console.log(logo);

var strs = new Array();
console.log(strs.length); //0
strs[0] = '基因';
strs[1] = '编辑';
console.log(strs.length); //2
strs[3] = '测试';
console.log(strs.length); //4
console.log(strs, strs[5]);

//for循环
for (var i = 0; i < strs.length; i++) {
    var item = strs[i];
    console.log(i, item);
}

//while
var i = 0;
while (i < strs.length) {
    console.log(i, strs[i]);
    i++;
}
//do....while
var i = 0;
do {
    console.log(i, strs[i]);
    i++;
}
while (i < strs.length);
//for...in 进行迭代、判断结束
for (var i in strs) {
    console.log(strs[i]);
}